package com.czb.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * Created by BIN on 2018-05-31.
 */
@Service
public class CarService {
    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "showError")   // 指定熔断方法
    public String show(String name){
        return restTemplate.getForObject("http://EUREKA-CLIENT/show?name=" + name, String.class);
    }


    public String showError(String name){
        return "show " + name + " error!";
    }
}
